package com.xwli.business.test;

/**
 * @program: soc-zj
 * @description:
 * @author: xwli
 * @create: 2023-01-05 18:47
 **/
public class CloudNetWorkServiceUtils {

    /**
    * @description:  根据上级订单号加接入点唯一标识生成新的上级订单号(解决一单多线重复上级订单号问题)
    * @params: [serialNo, netSideNo]
    * @return: java.lang.String
    * @author: xwli
    * @date: 2023/1/5 18:48
    */
    public static String getNewOrderSrcCode(String serialNo,String netSideNo){
        String[] spilts = netSideNo.split("-");
        String spiltStr = "_".concat(spilts[spilts.length - 2]).concat("-").concat(spilts[spilts.length-1]);
        serialNo = serialNo + spiltStr;
        return serialNo;
    }

    /**
    * @description: 判断是否是改造过后的上级订单号，如果是则还原回正确的上级订单号状态
    * @params: [serialNo, netSideNo]
    * @return: java.lang.String
    * @author: xwli
    * @date: 2023/1/5 20:00
    */
    public static String getOldOrderSrcCode(String serialNo,String netSideNo){
        String[] spilts = netSideNo.split("-");
        String spiltStr = "_".concat(spilts[spilts.length - 2]).concat("-").concat(spilts[spilts.length-1]);
        if (serialNo.contains(spiltStr)) {
            serialNo = serialNo.substring(0, serialNo.length() - spiltStr.length());
        }
        return serialNo;
    }

    public static void main(String[] args) {
        String serialNo = "CNSO-YZXKC-202301041745417126r57gn2qq4";
        String netSideNo = "CENO-NET-20230104171338-3SQYBnJ1S-2";
        String newOrderSrcCode = getNewOrderSrcCode(serialNo, netSideNo);
        System.out.println(newOrderSrcCode);
        String oldOrderSrcCode = getOldOrderSrcCode(newOrderSrcCode, netSideNo);
        System.out.println(oldOrderSrcCode);
        String str = "端到端业务测试衢州";
        String substring = str.substring(0, 8);
        System.out.println(substring);
    }

}
